package com.bjgzy.rating.mvp.ui.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.bjgzy.rating.R;
import com.bjgzy.rating.R2;
import com.eduhzy.ttw.commonres.utils.RxUtil;
import com.eduhzy.ttw.commonsdk.core.Constants;
import com.eduhzy.ttw.commonsdk.core.RouterHub;
import com.eduhzy.ttw.commonsdk.entity.RatingHomeData;
import com.eduhzy.ttw.commonsdk.utils.Utils;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.mvp.IView;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton;

import butterknife.BindView;
import butterknife.OnClick;

import static com.jess.arms.utils.Preconditions.checkNotNull;

/**
 * @author xubo
 * @date 2018-9-1 22:25:02
 */
@Route(path = RouterHub.RATING_UPLOADSUCCESSACTIVITY)
public class UploadSuccessActivity extends BaseActivity implements IView {
    @Autowired(name = Constants.ROUTER_DATA)
    RatingHomeData data;
    @BindView(R2.id.btn_my_works)
    QMUIRoundButton mBtnMyWorks;
    @BindView(R2.id.btn_home)
    QMUIRoundButton mBtnHome;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
        return R.layout.rating_activity_upload_success;
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mBtnMyWorks.setChangeAlphaWhenPress(true);
        mBtnHome.setChangeAlphaWhenPress(true);
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        RxUtil.showTipDialog(getActivity(), QMUITipDialog.Builder.ICON_TYPE_NOTHING, message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    public Activity getActivity() {
        return this;
    }

    @OnClick({R2.id.btn_my_works, R2.id.btn_home})
    public void onViewClicked(View view) {
        int i = view.getId();
        if (i == R.id.btn_my_works) {
            Utils.customNavigation(RouterHub.RATING_MYWORKSACTIVITY, Constants.MY_WORKS, data);
            killMyself();
        } else if (i == R.id.btn_home) {
            killMyself();
        }
    }
}
